package com.wwj.app.v1;

import com.wwj.core.wawa.entity.Item;
import com.wwj.core.wawa.service.IItemService;
import com.wwj.framework.controller.BaseController;
import com.wwj.framework.utils.ReturnData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/v1/item")
public class ItemController extends BaseController {

    @Resource
    private IItemService itemService;

    @RequestMapping("/list")
    @ResponseBody
    public ReturnData list() {
        ReturnData returnData = new ReturnData();
        try {
            List<Item> list = itemService.findByType(2);
            returnData.success(list);
        } catch (Exception e) {
            logger.error("", e);
            returnData.failure("系统错误,请联系客服");
        }
        return returnData;
    }
}
